﻿#ifndef AVFILESTOREAAC_H
#define AVFILESTOREAAC_H

#include <QHash>
#include "AVFileStoreAbstract.h"

class AVAudioConvert;

class AVFileStoreAAC : public AVFileStoreAbstract
{
    Q_OBJECT
public:
    AVFileStoreAAC(const QString &fileName);

    virtual bool init() override;
    virtual bool destory() override;


    virtual bool fillFrame(AVFrame *frame) override;
private:
    int flush_encoder(AVFormatContext *fmt_ctx,unsigned int stream_index);

private:
    AVFormatContext* m_formatCtx = nullptr;
    AVOutputFormat* m_fmt = nullptr;
    AVStream* m_audio_st = nullptr;
    AVCodecContext* m_codecCtx = nullptr;
    AVCodec* m_codec = nullptr;

    AVFrame *m_dstFrame = nullptr;
    AVPacket m_pkt;
    uint8_t * m_frame_buf = nullptr;

    QString m_fileName;
};

#endif // AVFILESTOREAAC_H
